package org.example.admin.controller;

import org.example.admin.exception.BizException;
import org.example.admin.exception.ControllerException;
import org.example.admin.service.NotifyViewRecordService;
import org.example.entity.NotifyViewRecord;

import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@CrossOrigin("*")
@RestController
@RequestMapping("/notifyView")
public class NotifyViewRecordController {
    private NotifyViewRecordService notifyViewRecordService;

    NotifyViewRecordController(NotifyViewRecordService notifyViewRecordService){
        this.notifyViewRecordService = notifyViewRecordService;
    }


    @PostMapping("/insert")
    private Object insert(NotifyViewRecord notifyViewRecord){
        System.out.println("控制层的nvr:"+notifyViewRecord);
        HashMap<String,Object> map = new HashMap<>();
        try{
            notifyViewRecordService.insert(notifyViewRecord);
            map.put("code",1);
            map.put("msg","success");
        }catch (BizException e){
            throw e;
        }catch (Exception ex){
            throw new ControllerException("控制层异常："+ex.getMessage());
        }

        return map;
    }


    //已读消息
}
